package patterns.filter;

import java.util.List;

/**
 * Created by lenovo on 2016/11/24 0024.
 * 具体标准实现类
 */
public class FilterAnd implements IFilter {
    //双重筛选标准共同作用
    private IFilter filter1;//标准1
    private IFilter filter2;//标准2

    public FilterAnd(IFilter filter1, IFilter filter2){
        this.filter1 = filter1;
        this.filter2 = filter2;
    }

    @Override
    public List<Person> matchCriteria(List<Person> personList) {
        List<Person> firstFilterList = filter1.matchCriteria(personList);
        //两种标准共同筛选。
        return filter2.matchCriteria(firstFilterList);
    }
}
